﻿/**
 * ...
 * @author sminutoli
 */
import com.dmotiko.prune.*
import com.dmotiko.general.*
import mx.transitions.easing.Regular;
import mx.transitions.easing.Strong;
import mx.transitions.Tween;
import mx.utils.Delegate;
 
class CollectionBar extends SiteBar
{
	
	public static var COLLECTION_1:String = "collection1.swf";
	public static var COLLECTION_2:String = "collection2.swf";
	public static var COLLECTION_3:String = "collection3.swf";
	
	private function initClip():Void {
		super.initClip();
		sLink = "MainCollectionBtn";
		setData( [ 
			{ label: "1", value: COLLECTION_1 },
			{ label: "2", value: COLLECTION_2 },
			{ label: "3", value: COLLECTION_3 }
		] );
	}
	
	private function section_changed(e):Void {
		if ( e.section == SiteSections.COLLECTION ) {
			btns[0].onRelease();
			this._x = 63;
			this._y = 325;
			show();
		} else {
			hide();
			if( Site.getApp().getClips().getCollection().isShowed() ) Site.getApp().getClips().getCollection().hide();
		}
	}
	
	
	public function show():Void
	{
		
		bShowing = true;
		
		var nX:Number = 0;
		for ( var i = 0; i < btns.length; i++){
			btns[i]._visible = true;
			var bCheck:Boolean =  i == btns.length -1;
			registerTween( "fadeBtn" + i, new Tween( btns[i], "_alpha", Regular.easeOut, btns[i]._alpha, 100, 0.7, true), false, bCheck  );
			registerTween( "moveBtn" + i, new Tween( btns[i], "_x", Strong.easeOut, btns[i]._x, nX, 1, true) );
			nX += btns[i]._width + 10;
		}
		
	}
	
	public function hide():Void
	{
		bShowing = true;
		
		for ( var i = 0; i < btns.length; i++){
			btns[i]._visible = true;
			var bCheck:Boolean =  i == btns.length -1;
			registerTween( "fadeBtn" + i, new Tween( btns[i], "_alpha", Regular.easeOut, btns[i]._alpha, 0, 0.7, true), false, bCheck  );
			registerTween( "moveBtn" + i, new Tween( btns[i], "_x", Strong.easeInOut, btns[i]._x, 0, 1, true) );
		}
		
	}
	
	private function btn_changed( e ):Void 
	{
		super.btn_changed(e);		
		Site.getApp().getClips().getMainContent().setData( e.data.value );
	}
	
}